#include <iostream>

#include <thread_pool.hpp>

#include "utils.h"

using namespace std;
using namespace ccq;

int main()
{
    cout << "Hello World!" << endl;

    ThreadPool pool(1);

    auto res = pool.post([](int a, int b){
        LOGI("{} + {} = {}", a, b, a+b);
        return a+b;
    }, 1, 2);
    res.get();
    for(int i = 1; i < 2; i++) {
        for(int j = 1; j < 20; j++) {
            pool.post([=]() {
                LOGI("{} * {} = {}", i, j, i*j);
                utils::msleep(1);
            });
        }
    }
    pool.clear();
    // pool.stop();

    concurrent::async([=]() {
        LOGI("async task");
        utils::msleep(1000);
    });

    pool.stop();
    try {
        pool.post([]() {});
    }
    catch(std::exception &e) {
        LOGE("Exception occured: {}", e.what());
    }

    return 0;
}
